<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="demo">
        <h1>XMLHttpRequest 对象</h1>
    </div>
    <button type="button" onclick="loadDoc()">修改内容</button>
</body>
<script>
    function loadDoc() {
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (this.readyState == 4 && this.status == 200) {
                document.getElementById("demo").innerHTML =
                    this.responseText;
            }
        };
        xhttp.open("GET", "https://liu.zzgoodqc.cn/hello", true);
        xhttp.send();

    }
</script>



<!-- <script>
    function loadXMLDoc() {
        var xmlhttp;
        if (window.XMLHttpRequest) {
            //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
            xmlhttp = new XMLHttpRequest();
        }
        else {
            // IE6, IE5 浏览器执行代码
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", "/try/ajax/ajax_info.txt", true);
        xmlhttp.send();
    }
</script>
</head>

<body>

    <div id="myDiv">
        <h2>使用 AJAX 修改该文本内容</h2>
    </div>
    <button type="button" onclick="loadXMLDoc()">修改内容</button>

</body> -->



<!-- <body>
    <div id="myDiv">
        <h1>使用AJAX更改文本内容</h1>
    </div>
    <button type="button" onclick="loadXMLDoc()">更改内容</button>
</body>
<script>
    function loadXMLDoc () {
        var xmlhttp = new XMLHttpRequest()
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById('myDiv').innerHTML = xmlhttp.responseText
            }
        }
        // xmlhttp.setRequestHeader('content-type')
        xmlhttp.open('GET','https://liu.zzgoodqc.cn/blogs')
        xmlhttp.send()



        if (window.XMLHttpRequest){
            xmlhttp = new XMLHttpRequest();
        }else{
            xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
        }
        xmlhttp.onreadystatechenge = function () {
            if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                doucment.getElementByID('box').innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open('GET','/try/ajax/ajax_info.txt',true);
        xmlhttp.send()

    }
</script> -->

</html>